/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.portlet.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;

import com.portlet.model.bophan;
import com.portlet.model.bophanModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the bophan service. Represents a row in the &quot;dtbase_bophan&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.portlet.model.bophanModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link bophanImpl}.
 * </p>
 *
 * @author Thi
 * @see bophanImpl
 * @see com.portlet.model.bophan
 * @see com.portlet.model.bophanModel
 * @generated
 */
public class bophanModelImpl extends BaseModelImpl<bophan>
	implements bophanModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a bophan model instance should use the {@link com.portlet.model.bophan} interface instead.
	 */
	public static final String TABLE_NAME = "dtbase_bophan";
	public static final Object[][] TABLE_COLUMNS = {
			{ "maBoPhan", Types.VARCHAR },
			{ "tenBoPhan", Types.VARCHAR },
			{ "ghiChu", Types.VARCHAR }
		};
	public static final String TABLE_SQL_CREATE = "create table dtbase_bophan (maBoPhan VARCHAR(75) not null primary key,tenBoPhan VARCHAR(75) null,ghiChu VARCHAR(75) null)";
	public static final String TABLE_SQL_DROP = "drop table dtbase_bophan";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.portlet.model.bophan"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.portlet.model.bophan"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = false;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.portlet.model.bophan"));

	public bophanModelImpl() {
	}

	public String getPrimaryKey() {
		return _maBoPhan;
	}

	public void setPrimaryKey(String primaryKey) {
		setMaBoPhan(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return _maBoPhan;
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey((String)primaryKeyObj);
	}

	public Class<?> getModelClass() {
		return bophan.class;
	}

	public String getModelClassName() {
		return bophan.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("maBoPhan", getMaBoPhan());
		attributes.put("tenBoPhan", getTenBoPhan());
		attributes.put("ghiChu", getGhiChu());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		String maBoPhan = (String)attributes.get("maBoPhan");

		if (maBoPhan != null) {
			setMaBoPhan(maBoPhan);
		}

		String tenBoPhan = (String)attributes.get("tenBoPhan");

		if (tenBoPhan != null) {
			setTenBoPhan(tenBoPhan);
		}

		String ghiChu = (String)attributes.get("ghiChu");

		if (ghiChu != null) {
			setGhiChu(ghiChu);
		}
	}

	public String getMaBoPhan() {
		if (_maBoPhan == null) {
			return StringPool.BLANK;
		}
		else {
			return _maBoPhan;
		}
	}

	public void setMaBoPhan(String maBoPhan) {
		_maBoPhan = maBoPhan;
	}

	public String getTenBoPhan() {
		if (_tenBoPhan == null) {
			return StringPool.BLANK;
		}
		else {
			return _tenBoPhan;
		}
	}

	public void setTenBoPhan(String tenBoPhan) {
		_tenBoPhan = tenBoPhan;
	}

	public String getGhiChu() {
		if (_ghiChu == null) {
			return StringPool.BLANK;
		}
		else {
			return _ghiChu;
		}
	}

	public void setGhiChu(String ghiChu) {
		_ghiChu = ghiChu;
	}

	@Override
	public bophan toEscapedModel() {
		if (_escapedModel == null) {
			_escapedModel = (bophan)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelInterfaces, new AutoEscapeBeanHandler(this));
		}

		return _escapedModel;
	}

	public bophan toUnescapedModel() {
		return (bophan)this;
	}

	@Override
	public Object clone() {
		bophanImpl bophanImpl = new bophanImpl();

		bophanImpl.setMaBoPhan(getMaBoPhan());
		bophanImpl.setTenBoPhan(getTenBoPhan());
		bophanImpl.setGhiChu(getGhiChu());

		bophanImpl.resetOriginalValues();

		return bophanImpl;
	}

	public int compareTo(bophan bophan) {
		String primaryKey = bophan.getPrimaryKey();

		return getPrimaryKey().compareTo(primaryKey);
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}

		if (!(obj instanceof bophan)) {
			return false;
		}

		bophan bophan = (bophan)obj;

		String primaryKey = bophan.getPrimaryKey();

		if (getPrimaryKey().equals(primaryKey)) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return getPrimaryKey().hashCode();
	}

	@Override
	public void resetOriginalValues() {
	}

	@Override
	public CacheModel<bophan> toCacheModel() {
		bophanCacheModel bophanCacheModel = new bophanCacheModel();

		bophanCacheModel.maBoPhan = getMaBoPhan();

		String maBoPhan = bophanCacheModel.maBoPhan;

		if ((maBoPhan != null) && (maBoPhan.length() == 0)) {
			bophanCacheModel.maBoPhan = null;
		}

		bophanCacheModel.tenBoPhan = getTenBoPhan();

		String tenBoPhan = bophanCacheModel.tenBoPhan;

		if ((tenBoPhan != null) && (tenBoPhan.length() == 0)) {
			bophanCacheModel.tenBoPhan = null;
		}

		bophanCacheModel.ghiChu = getGhiChu();

		String ghiChu = bophanCacheModel.ghiChu;

		if ((ghiChu != null) && (ghiChu.length() == 0)) {
			bophanCacheModel.ghiChu = null;
		}

		return bophanCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(7);

		sb.append("{maBoPhan=");
		sb.append(getMaBoPhan());
		sb.append(", tenBoPhan=");
		sb.append(getTenBoPhan());
		sb.append(", ghiChu=");
		sb.append(getGhiChu());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(13);

		sb.append("<model><model-name>");
		sb.append("com.portlet.model.bophan");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>maBoPhan</column-name><column-value><![CDATA[");
		sb.append(getMaBoPhan());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>tenBoPhan</column-name><column-value><![CDATA[");
		sb.append(getTenBoPhan());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>ghiChu</column-name><column-value><![CDATA[");
		sb.append(getGhiChu());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = bophan.class.getClassLoader();
	private static Class<?>[] _escapedModelInterfaces = new Class[] { bophan.class };
	private String _maBoPhan;
	private String _tenBoPhan;
	private String _ghiChu;
	private bophan _escapedModel;
}